﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using V = Science.Mathematics.VectorCalculus;

namespace VectorCalculus5Ed.Chapter4.Section1
{
    public class Example02
    {
        public Example02()
		{
		}
		private string result;
		public string Result
		{
			get{return result;}
		}
        public void Compute()
        {
            V.Function.ToLastType<double, double[]> f
                = new V.Function.ToLastType<double, double[]>(func);
            V.Path p = new V.Path(f);
            V.Velocity v = new V.Velocity(p, 1.0);
            v.Compute();
            result += v[0].ToString() + "\r\n";
            result += v[1].ToString() + "\r\n";
            result += v[2].ToString() + "\r\n";

            V.Acceleration a = new V.Acceleration(p, 1.0);
            a.Compute();
            result += a[0].ToString() + "\r\n";
            result += a[1].ToString() + "\r\n";
            result += a[2].ToString() + "\r\n";    
        }
        private double[] func(double t)
        {
            double[] c = new double[3];
            c[0] = t;
            c[1] = t;
            c[2] = 1.0 - 0.5 * t * t;
            return c;
        }
    }
}

/*
0.999999999999923
0.999999999999923
-0.999999999999923
-2.61365003713839E-11
-2.61365003713839E-11
-0.999999999974952
*/